<template>
  <div class="single-preview">
    <single-logic :tagConfigJson="tagConfigJson"></single-logic>
    <single-result :config="config"></single-result>
    <div class="preview-story">
      <div class="story-box">
        <div class="story-title linear-orange">
          <span class="icon"><icon-svg name="iconCalculateTag"></icon-svg></span><br />
          标签故事
        </div>
        <div class="story-content story-text">
          <el-input type="textarea" v-model="config.tagStory" :rows="8" resize="none" disabled></el-input>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import singleLogic from './single-logic'
import singleResult from './single-result'
export default {
  props: {
    config: {
      type: [Object, String],
      required: true,
      default: () => {}
    }
  },
  components: { singleLogic, singleResult },
  computed: {
    tagConfigJson() {
      let tagConfigJson = this.config.tagConfigJson
      if (typeof this.config.tagConfigJson === 'string') tagConfigJson = JSON.parse(this.config.tagConfigJson)
      return tagConfigJson
    }
  },
  data() {
    return {}
  },
  methods: {}
}
</script>

<style lang="scss">
.single-preview {
  height: 100%;
  display: flex;
  flex-direction: column;
  .preview-story {
    height: 200px;
    .story-box {
      height: 180px;
    }
    .icon {
      margin-top: 40px;
    }
    .el-textarea.is-disabled .el-textarea__inner {
      color: #000;
      cursor: default;
    }
  }
  .story-box {
    margin-top: 10px;
    height: 290px;
    border-radius: 5px;
    box-shadow: 1px 1px 3px #ddd, -1px -1px 3px #ddd;
    overflow: hidden;
    position: relative;
  }
  .story-title {
    font-size: 17px;
    font-weight: bold;
    width: 200px;
    height: 100%;
    color: #fff;
    text-align: center;
    position: relative;
    &:before {
      width: 100%;
      height: 100%;
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      background: url(~@/assets/img/params_bg.png) no-repeat 0px 0px/100% 100%;
    }
  }
  .icon {
    display: inline-block;
    width: 80px;
    height: 80px;
    background-color: #fff;
    margin: 80px 0 10px;
    border-radius: 50%;
    svg {
      width: 50px;
      height: 50px;
      margin-top: 15px;
    }
  }
  .linear-orange {
    background: linear-gradient(to bottom, #f3bf7c, #f3b172);
    svg {
      color: #f3b172;
    }
  }
  .linear-blue {
    background: linear-gradient(to bottom, #63a3fc, #5188ec);
    svg {
      color: #5188ec;
    }
  }
  .story-content {
    padding-left: 200px;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }
  .result-title {
    font-weight: bold;
    height: 60px;
    border-bottom: 1px solid #eee;
    span {
      display: inline-block;
      width: 80%;
      height: 40px;
      line-height: 40px;
      margin: 10px 0 10px 0;
      background-color: #fcf5e5;
      border-radius: 20px;
    }
  }
  .result-content {
    height: calc(100% - 60px);
    overflow-y: auto;
    li {
      height: 40px;
      line-height: 40px;
      text-align: center;
    }
  }
}
</style>
